﻿using WYJ.SDK.Core;
using WYJ.SDK.Core.Json;

internal static class App
{
    internal static readonly string? ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
    internal static AppSetting Setting { get; set; }

    internal static void Run(string[] args)
    {
        try
        {
            Setting = JsonLoader.Load<AppSetting>($"{ApplicationBase}/appsettings.json");
            switch (args.Length)
            {
                case 0:
                    Handler.Invoke("Watch");
                    break;
                case 1:
                    Handler.Invoke(args[0]);
                    break;
                default:
                    Handler.Invoke(args[0], args[1..]);
                    break;
            };
        }
        catch (Exception e)
        {
            WYJConsole.PrintException(e);
        }
    }

}